package org.jeecg.modules.lab.items.temp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.lab.items.temp.entity.LabItemsTempSample;
import org.jeecg.modules.lab.items.temp.mapper.LabItemsTempSampleMapper;
import org.jeecg.modules.lab.items.temp.service.ILabItemsTempSampleService;
import org.jeecg.modules.lab.items.vo.LabTempSam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @Description: 实验项目模板_样品信息
 * @Author: jeecg-boot
 * @Date:   2023-10-08
 * @Version: V1.0
 */
@Service
public class LabItemsTempSampleServiceImpl extends ServiceImpl<LabItemsTempSampleMapper, LabItemsTempSample> implements ILabItemsTempSampleService {

    @Autowired
    private LabItemsTempSampleMapper labItemsTempSampleMapper;

    @Override
    public List<LabTempSam> handTempData(String itemId) {
        List<LabTempSam> tempSamList = labItemsTempSampleMapper.getTempSamList(itemId);
        QueryWrapper<LabItemsTempSample> queryWrapper = new QueryWrapper<>();
        for (LabTempSam labTempSam : tempSamList) {
            queryWrapper.clear();
            queryWrapper.eq("field_row", labTempSam.getSId())
                    .eq("item_id", itemId)
                    .orderByAsc("field_sort");
            List<LabItemsTempSample> itemsTempSampleList = labItemsTempSampleMapper.selectList(queryWrapper);
            labTempSam.setLabItemsTempSampleList(itemsTempSampleList);
        }
        return tempSamList;
    }
}
